﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using JBeamLibrary.Tools;
using JBeamLibrary.VehicleParts.Elements;
using JBeamLibrary.VehicleParts.Enums;
using JBeamLibrary.VehicleParts.Groups;
using JBeamLibrary.VehicleParts.Interfaces;

namespace JBeamLibrary.Exceptions
{
    public class InvalidPropertyException<T> : DriveException where T : class, IVehicleElement
    {
        #region Properties

        public VehicleSection<T> Section { get; private set; }

        public ElementProperties Property { get; private set; }

        public ElementPropertyUse Use { get; private set; }

        public object Value { get; private set; }

        #endregion

        #region CTORs

        public InvalidPropertyException(VehicleSection<T> section, ElementProperty prop, ArgumentException ex = null)
            : base(string.Format("The {0} property '{1}' with value '{2}' is not valid in section '{3}' of part '{4}' of file '{5}'", prop.Use, prop.Property, prop.Value.ToStringOrEmpty(), section.Name, section.Part.Name, section.Part.File.Name), ex)
        {
            Section = section;
            Property = prop.Property;
            Use = prop.Use;
            Value = prop.Value;
        }

        public InvalidPropertyException(VehicleSection<T> section, ElementProperties prop, object value, ElementPropertyUse use, ArgumentException ex = null)
            : base(string.Format("The {0} property '{1}' with value '{2}' is not valid in section '{3}' of part '{4}' of file '{5}'", use, prop, value.ToStringOrEmpty(), section.Name, section.Part.Name, section.Part.File.Name), ex)
        {
            Section = section;
            Property = prop;
            Use = use;
            Value = value;
        }

        #endregion
    }
}
